package com.lili.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.lili.controller.request.*;
import com.lili.po.*;
import com.lili.service.XasUserInfoService;
import com.lili.uitl.ConvertUtil;
import com.lili.vo.MyPage;
import com.lili.vo.ResponseResult;
import com.lili.vo.XasUserInfoVo;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("userInfo")
public class XasUserInfoController {
    @Autowired
    XasUserInfoService xasUserInfoService;


    //用户信息 按照姓名和手机号查询，可以修改vip等级
    @RequestMapping("userInfoListPage")
    public ResponseResult xasUserInfoList(@RequestBody XasUserInfoRequest xasUserInfoRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserInfoRequest, myPage);
        IPage<XasUserInfo> iPage = xasUserInfoService.xasUserInfoList(xasUserInfoRequest);
        List<XasUserInfoVo> resultList = ConvertUtil.copyTo(iPage.getRecords(), XasUserInfoVo.class);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(resultList);
        responseResult.setData(myPage);
        return responseResult;
    }

    //用户关系
    @RequestMapping("xasUserRelationship")
    public ResponseResult xasUserRelationship(@RequestBody XasUserInfoRequest xasUserInfoRequest) {
        ResponseResult responseResult = new ResponseResult();
        List<XasUserInfo> xasUserInfos = xasUserInfoService.xasUserRelationship(xasUserInfoRequest.getPhone(), xasUserInfoRequest.getType());
        responseResult.setData(xasUserInfos);
        return responseResult;
    }


    //收货地址 按照手机号和收货人姓名查询
    @RequestMapping("xasUserAddressList")
    public ResponseResult xasUserAddressList(@RequestBody XasUserAddressListRequest xasUserAddressListRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserAddressListRequest, myPage);
        IPage<XasUserAddressList> iPage = xasUserInfoService.xasUserAddressList(xasUserAddressListRequest);
        List<XasUserAddressList> resultList = ConvertUtil.copyTo(iPage.getRecords(), XasUserAddressList.class);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(resultList);
        responseResult.setData(myPage);
        return responseResult;
    }


    //积分记录 按用户手机号和时间段查询
    @RequestMapping("xasUserPointRecordsListByPhone")
    public ResponseResult xasUserPointRecordsListByPhone(@RequestBody XasUserPointRecordsRequest xasUserPointRecordsRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserPointRecordsRequest, myPage);
        IPage<XasUserPointRecords> iPage = xasUserInfoService.xasUserPointRecordsListByPhone(xasUserPointRecordsRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }


    //余额记录 按用户手机号和时间段查询
    @RequestMapping("xasUserBalanceRecordsListByPhone")
    public ResponseResult xasUserBalanceRecordsListByPhone(@RequestBody XasUserBalanceRecordsRequest xasUserBalanceRecordsRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserBalanceRecordsRequest, myPage);
        IPage<XasUserBalanceRecords> iPage = xasUserInfoService.xasUserBalanceRecordsListByPhone(xasUserBalanceRecordsRequest);
        List<XasUserBalanceRecords> resultList = ConvertUtil.copyTo(iPage.getRecords(), XasUserBalanceRecords.class);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(resultList);
        responseResult.setData(myPage);
        return responseResult;
    }


    //收益记录 按用户手机号和时间段查询  xas_user_benefits_records
    @RequestMapping("xasUserBenefitsRecordsListByPhone")
    public ResponseResult xasUserBenefitsRecordsListByPhone(@RequestBody XasUserBenefitsRecordsRequest xasUserBenefitsRecordsRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserBenefitsRecordsRequest, myPage);
        IPage<XasUserBenefitsRecords> iPage = xasUserInfoService.xasUserBenefitsRecordsListByPhone(xasUserBenefitsRecordsRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    //平台币记录  按用户手机号和时间段查询
    @RequestMapping("xasUserCoinRecordsListByPhone")
    public ResponseResult xasUserCoinRecordsListByPhone(@RequestBody XasUserCoinRecordsRequest xasUserCoinRecordsRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserCoinRecordsRequest, myPage);
        IPage<XasUserCoinRecords> iPage = xasUserInfoService.xasUserCoinRecordsListByPhone(xasUserCoinRecordsRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    //银行卡 按照用户手机号查询
    @RequestMapping("xasUserBankcardListByPhone")
    public ResponseResult xasUserBankcardListByPhone(@RequestBody XasUserBankcardListRequest xasUserBankcardListRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserBankcardListRequest, myPage);
        IPage<XasUserBankcardList> iPage = xasUserInfoService.xasUserBankcardListByPhone(xasUserBankcardListRequest);;
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    //实名认证 按照用户手机号查询
    @RequestMapping("xasUserAuthenticationRecords")
    public ResponseResult xasUserAuthenticationRecords(@RequestBody XasUserAuthenticationRecordsRequest xasUserAuthenticationRecordsRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserAuthenticationRecordsRequest, myPage);
        IPage<XasUserAuthenticationRecords> iPage = xasUserInfoService.xasUserAuthenticationRecords(xasUserAuthenticationRecordsRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }


    @RequestMapping("examineXasUserAuthenticationRecords")
    public ResponseResult examineXasUserAuthenticationRecords(@RequestBody XasUserAuthenticationRecordsRequest xasUserAuthenticationRecordsRequest) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.examineXasUserAuthenticationRecords(xasUserAuthenticationRecordsRequest.getId(), xasUserAuthenticationRecordsRequest.getStatus());
        return responseResult;
    }


    //会员
    @RequestMapping("selectXasVipPrice")
    public ResponseResult selectXasVipPrice(@RequestBody XasVipPriceRequest xasVipPriceRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasVipPriceRequest, myPage);
        IPage<XasVipPrice> iPage = xasUserInfoService.selectXasVipPrice(xasVipPriceRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    @RequestMapping("selectAllXasVipPrice")
    public ResponseResult selectAllXasVipPrice() {
        ResponseResult responseResult = new ResponseResult();
        List<XasVipPrice> xasVipPriceList  = xasUserInfoService.selectAllXasVipPrice();
        responseResult.setData(xasVipPriceList);
        return responseResult;
    }


    @RequestMapping("addXasVipPrice")
    public ResponseResult addXasVipPrice(@RequestBody XasVipPrice xasVipPrice) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.addXasVipPrice(xasVipPrice);
        return responseResult;
    }

    @RequestMapping("updateXasVipPrice")
    public ResponseResult updateXasVipPrice(@RequestBody XasVipPrice xasVipPrice) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.updateXasVipPrice(xasVipPrice);
        return responseResult;
    }

    @RequestMapping("delXasVipPrice")
    public ResponseResult delXasVipPrice(@RequestBody XasVipPrice xasVipPrice) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.delXasVipPrice(xasVipPrice.getId());
        return responseResult;
    }


    @RequestMapping("selectXasVipPrivilege")
    public ResponseResult selectXasVipPrivilege(@RequestBody XasVipPrivilegeRequest xasVipPrivilegeRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasVipPrivilegeRequest, myPage);
        IPage<XasVipPrivilege> iPage = xasUserInfoService.selectXasVipPrivilege(xasVipPrivilegeRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    @RequestMapping("addXasVipPrivilege")
    public ResponseResult addXasVipPrivilege(@RequestBody XasVipPrivilege xasVipPrivilege) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.addXasVipPrivilege(xasVipPrivilege);
        return responseResult;
    }

    @RequestMapping("updateXasVipPrivilege")
    public ResponseResult updateXasVipPrivilege(@RequestBody XasVipPrivilege xasVipPrivilege) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.updateXasVipPrivilege(xasVipPrivilege);
        return responseResult;
    }

    @RequestMapping("delXasVipPrivilege")
    public ResponseResult delXasVipPrivilege(@RequestBody XasVipPrivilege xasVipPrivilege) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.delXasVipPrivilege(xasVipPrivilege.getId());
        return responseResult;
    }


    @RequestMapping("selectXasUserShoppingCartList")
    public ResponseResult selectXasUserShoppingCartList(@RequestBody XasUserInfoRequest xasUserInfoRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasUserInfoRequest, myPage);
        IPage<XasUserShoppingCartList> iPage = xasUserInfoService.selectXasUserShoppingCartList(xasUserInfoRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    @RequestMapping("selectXasMsgNotification")
    public ResponseResult selectXasMsgNotification(@RequestBody XasMsgNotificationRequest xasMsgNotificationRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasMsgNotificationRequest, myPage);
        IPage<XasMsgNotification> iPage = xasUserInfoService.selectXasMsgNotification(xasMsgNotificationRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    @RequestMapping("selectXasMsgSystem")
    public ResponseResult selectXasMsgSystem(@RequestBody XasMsgNotificationRequest xasMsgNotificationRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasMsgNotificationRequest, myPage);
        IPage<XasMsgSystem> iPage = xasUserInfoService.selectXasMsgSystem(xasMsgNotificationRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    @RequestMapping("addXasMsgSystem")
    public ResponseResult addXasMsgSystem(@RequestBody XasMsgSystem xasMsgSystem) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.addXasMsgSystem(xasMsgSystem);
        return responseResult;
    }

    @RequestMapping("updateXasMsgSystem")
    public ResponseResult updateXasMsgSystem(@RequestBody XasMsgSystem xasMsgSystem) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.updateXasMsgSystem(xasMsgSystem);
        return responseResult;
    }

    @RequestMapping("delXasMsgSystem")
    public ResponseResult delXasMsgSystem(@RequestBody XasMsgSystem xasMsgSystem) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.delXasMsgSystem(xasMsgSystem.getId());
        return responseResult;
    }


    @RequestMapping("selectXasSysConfig")
    public ResponseResult selectXasSysConfig(@RequestBody XasMsgNotificationRequest xasMsgNotificationRequest) {
        ResponseResult responseResult = new ResponseResult();
        MyPage myPage = new MyPage();
        BeanUtils.copyProperties(xasMsgNotificationRequest, myPage);
        IPage<XasSysConfig> iPage = xasUserInfoService.selectXasSysConfig(xasMsgNotificationRequest);
        myPage.setTotal(iPage.getTotal());
        myPage.setRecords(iPage.getRecords());
        responseResult.setData(myPage);
        return responseResult;
    }

    @RequestMapping("addXasSysConfig")
    public ResponseResult addXasSysConfig(@RequestBody XasSysConfig xasSysConfig) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.addXasSysConfig(xasSysConfig);
        return responseResult;
    }

    @RequestMapping("updateXasSysConfig")
    public ResponseResult updateXasSysConfig(@RequestBody XasSysConfig xasSysConfig) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.updateXasSysConfig(xasSysConfig);
        return responseResult;
    }

    @RequestMapping("delXasSysConfig")
    public ResponseResult delXasSysConfig(@RequestBody XasSysConfig xasSysConfig) {
        ResponseResult responseResult = new ResponseResult();
        xasUserInfoService.delXasSysConfig(xasSysConfig.getId());
        return responseResult;
    }

}
